package com.zidongxiangxi.rabbit.producer.mapper;

import com.zidongxiangxi.rabbit.producer.entity.Producer;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Producer的mapper类
 *
 * @author chenxudong
 * @date 2020/11/07
 */
public class ProducerMapper implements RowMapper<Producer> {
	@Override
	public Producer mapRow(ResultSet rs, int rowNum) throws SQLException {
		Producer producer = new Producer();
		producer.setId(rs.getLong("id"));
		producer.setType(rs.getInt("type"));
		producer.setApplication(rs.getString("application"));
		producer.setHost(rs.getString("host"));
		producer.setPort(rs.getInt("port"));
		producer.setVirtualHost(rs.getString("virtual_host"));
		producer.setExchange(rs.getString("exchange"));
		producer.setRoutingKey(rs.getString("routing_key"));
		producer.setMessageId(rs.getString("message_id"));
		producer.setMessage(rs.getBytes("message"));
		producer.setSendStatus(rs.getInt("send_status"));
		producer.setRetryTimes(rs.getInt("retry_times"));
		producer.setMaxRetryTimes(rs.getInt("max_retry_times"));
		producer.setNextRetryTime(rs.getDate("next_retry_time"));
		producer.setCreateTime(rs.getDate("create_time"));
		producer.setUpdateTime(rs.getDate("update_time"));
		return producer;
	}
}
